You can use the rendering extensions for Image, HTML, PDF, XML or Word to render a page report in any of the supported formats. See Rendering for details on rendering formats.
The following steps provide an example of rendering a report in the format.
- In Visual Studio, create a new Windows Forms Application or open an existing one.
- On the Form.cs or Form.vb that opens, double-click the title bar to create the Form_Load event.
- Add the following code inside the Form_Load event.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Form Load event. | Copy Code |
---|---|
' Provide the page report you want to render. Dim _reportDef As New GrapeCity.ActiveReports.PageReport(New System.IO.FileInfo("C:\MovieRatings.rdlx")) Dim _reportRuntime As New GrapeCity.ActiveReports.Document.PageDocument(_reportDef) ' Set the file format you want the report to be rendered in. Dim exportFile As String = System.IO.Path.GetTempFileName() + ".pdf" Dim myFile As New System.IO.FileInfo(exportFile) ' Provide settings for your rendering output. Dim settings As New GrapeCity.ActiveReports.Export.Pdf.Page.Settings() settings.HideToolbar = True settings.HideMenubar = True settings.HideWindowUI = True ' Set the rendering extension and render the report. Dim _renderingExtension As New GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension() Dim _provider As New GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(myFile.Directory, System.IO.Path.GetFileNameWithoutExtension(myFile.Name)) _reportRuntime.Render(_renderingExtension, _provider, settings) System.Diagnostics.Process.Start(exportFile) |
C# code. Paste INSIDE the Form Load event. | Copy Code |
---|---|
// Provide the page report you want to render. GrapeCity.ActiveReports.PageReport _reportDef = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(@"C:\MovieRatings.rdlx")); GrapeCity.ActiveReports.Document.PageDocument _reportRuntime = new GrapeCity.ActiveReports.Document.PageDocument(_reportDef); // Set the file format you want the report to be rendered in. string exportFile = System.IO.Path.GetTempFileName() + ".pdf"; System.IO.FileInfo myFile = new System.IO.FileInfo(exportFile); // Provide settings for your rendering output. GrapeCity.ActiveReports.Export.Pdf.Page.Settings settings = new GrapeCity.ActiveReports.Export.Pdf.Page.Settings(); settings.HideToolbar = true; settings.HideMenubar = true; settings.HideWindowUI = true; // Set the rendering extension and render the report. GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension _renderingExtension = new GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension(); GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider _provider = new GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(myFile.Directory, System.IO.Path.GetFileNameWithoutExtension(myFile.Name)); _reportRuntime.Render(_renderingExtension, _provider, settings); System.Diagnostics.Process.Start(exportFile); |
Note: The code above works for any supported rendering format. Simply, replace the instances of PDF with the specific rendering format type and use the desired rendering extension. |